using System;
using System.Collections.Generic;
using SiemensAmd.Mmt.Amd.McisDbModel;
using SqlSugar;
using SqlSugarEx.Utilities;

namespace SiemensAmd.Mmt.Amd.McisDbDal
{
	public class TrgToolDataDetailsDal
	{
		private readonly SqlSugarClient _sqlSugar;

		public TrgToolDataDetailsDal(string server, string db, string user, string pwd)
		{
			this._sqlSugar = new SqlSugarClient(new ConnectionConfig
			{
				DbType = DbType.SqlServer,
				ConnectionString = DbUtility.SQLDbFormat(server, db, user, pwd),
				IsAutoCloseConnection = false
			});
		}

		public bool IsDataChanged(Func<bool> funcClearTb = null)
		{
			bool flag = this._sqlSugar.Queryable<TrgToolDataDetailsEntity>().Count() > 0;
			if (flag && (funcClearTb?.Invoke() ?? false))
			{
				this._sqlSugar.Deleteable<TrgToolDataDetailsEntity>().ExecuteCommand();
			}
			return flag;
		}

		public List<TrgToolDataDetailsEntity> TrgToolDataMonitor()
		{
			return this._sqlSugar.Queryable<TrgToolDataDetailsEntity>().ToList();
		}

		public int Clear(long[] pkBuff)
		{
			return this._sqlSugar.Deleteable<TrgToolDataDetailsEntity>(pkBuff).ExecuteCommand();
		}
	}
}
